
;;; @see SICP exercise 2.19
(defparameter us-coins (list 50 25 10 5 1))
(defparameter uk-coins (list 100 50 20 10 5 2 1 0.5))

(defun no-more? (coin-values)
  (null coin-values))

(defun except-first-denomination (coin-values)
  (cdr coin-values))

(defun first-denomination (coin-values)
  (car coin-values))

(defun cc (amount coin-values)
  (cond ((= amount 0) 1)
        ((or (< amount 0) (no-more? coin-values)) 0)
        (t
         (+ (cc amount
                (except-first-denomination coin-values))
            (cc (- amount
                   (first-denomination coin-values))
                coin-values)))))

(defun count-change (amount &optional (coin-values us-coins))
  (cc amount coin-values))

(defun p-31 ()
  (count-change 200 '(200 100 50 20 10 5 2 1)))

;;; test
(print (time (p-31)))
